function HTMLcompressor(){

var allHTML = document.getElementById("oldCode").value;
var headstatus = document.getElementById("headstatus").checked;

var docSplit = "<html"; 
allHTML_array = allHTML.split(new RegExp(docSplit,'i'));
var dtHTML = allHTML_array[0];//doctype
var ndtHTML = allHTML_array[1];

var bodySplit = "<body"; 
newCode = ndtHTML.split(new RegExp(bodySplit,'i'));
var headHTML = newCode[0];
var bodyHTML = newCode[1];

if(headstatus != true){
	var removeThis = "\r\n";
	headHTML = headHTML.replace(new RegExp(removeThis, "gi"), "" );
	var removeThis = "\n";
	headHTML = headHTML.replace(new RegExp(removeThis, "gi"), "" );
	var removeThis = "\t";
	headHTML = headHTML.replace(new RegExp(removeThis, "gi"), "" );
	var removeThis = /\s+/g;
	headHTML = headHTML.replace(removeThis," ");
}

var removeThis = "\r\n";
bodyHTML = bodyHTML.replace(new RegExp(removeThis, "gi"), "" );
var removeThis = "\n";
bodyHTML = bodyHTML.replace(new RegExp(removeThis, "gi"), "" );
var removeThis = "\t";
bodyHTML = bodyHTML.replace(new RegExp(removeThis, "gi"), "" );
var removeThis = /\s+/g;
bodyHTML = bodyHTML.replace(removeThis," ");

var compressedHTML = dtHTML+"<html"+headHTML+"<body"+bodyHTML;

document.getElementById("newCode").value = compressedHTML;
}
